home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
vsc92nov.zip
/
gcstat.c
< prev
next >
Wrap
Text File
|
1992-11-02
|
2KB
|
83 lines
/*
* gcstat.c -- Implementation of gc_statistics_proc for Scheme
*
* (C) m.b (Matthias Blume), Mon May 25 11:38:25 MET DST 1992, HUB/Ger
* Humboldt-University of Berlin, Germany
*/
# ident "@(#)gcstat.c (C) M.Blume, Humboldt-Uni Berlin, 1.4"
# include <stdio.h>
# include "storage.h"
# include "Cont.h"
# include "Code.h"
# include "Number.h"
# include "Vector.h"
# include "speccont.h"
# include "mode.h"
# include "except.h"
# if (1000 < CLOCKS_PER_SEC)
# define CLK2MS(clk) ((clk)/(CLOCKS_PER_SEC/1000))
# else
# define CLK2MS(clk) (((clk)*1000)/CLOCKS_PER_SEC)
# endif
void gc_statistics_proc (
size_t gbc, size_t nobj, size_t min, size_t total, size_t used, clock_t clk)
{
void *gcmode = ScmMode (SCM_GC_STRATEGY_MODE);
void *tmp;
ScmVector *vect;
static size_t previous_min = 0;
clk = CLK2MS (clk);
if (gcmode == NULL) {
fprintf (stderr, "GC: called after %lu getbytes-calls,\n"
" found %lu active objects in %ld Milliseconds\n"
" memory usage: %lu of %lu heap elements (%lu%%)\n",
(unsigned long) gbc,
(unsigned long) nobj,
(long) clk,
(unsigned long) used, (unsigned long) total,
total == 0 ? 100 : (unsigned long) ((used * 100) / total));
if (min < previous_min) {
previous_min = min;
reset ("Reset due to memory allocation problem");
}
if (2 * used > min)
gc_set_min_heap_size (2 * used);
} else {
vect = NewScmVector (8);
ScmPush (vect);
gcmode = ScmMode (SCM_GC_STRATEGY_MODE);
vect = ScmPeek ();
vect->array [0] = gcmode;
tmp = ScmIntToExactNumber (gbc);
vect = ScmPeek ();
vect->array [1] = tmp;
tmp = ScmIntToExactNumber (nobj);
vect = ScmPeek ();
vect->array [2] = tmp;
tmp = ScmIntToExactNumber (min);
vect = ScmPeek ();
vect->array [3] = tmp;
tmp = ScmIntToExactNumber (previous_min);
vect = ScmPeek ();
vect->array [4] = tmp;
tmp = ScmIntToExactNumber (total);
vect = ScmPeek ();
vect->array [5] = tmp;
tmp = ScmIntToExactNumber (used);
vect = ScmPeek ();
vect->array [6] = tmp;
tmp = ScmIntToExactNumber ((long) clk);
vect = ScmPop ();
vect->array [7] = tmp;
ScmRegisterInterrupt (SCM_VM_GC_STRAT_CONT, vect);
}
previous_min = min;
}